using System;
using System.Threading;
using CriticalSystems.Instrumentation.Configuration;
using CriticalSystems.Instrumentation.Internal;
using Trace=System.Diagnostics.Trace;

namespace CriticalSystems.Instrumentation.TraceWriters
{
    internal class SystemDiagnosticTraceWriter : ITraceWriter
    {
        #region ITraceWriter Members
        public TracingFlags Flags
        {
            get { return InstrumentationConfiguration.Instance.Tracing; }
        }

        public void Write(TraceType traceType, int indent, string instance, string type, string method, string text)
        {
            string typeText = SimpleTraceWriterWrapper.GetTypeText(type, instance);
            string fullText = string.Format("\t[{0}]{1} {2} {3}.{4} : {5}", Thread.CurrentThread.ManagedThreadId, SimpleTraceWriterWrapper.GetTracePrefix(traceType),
                                            SimpleTraceWriterWrapper.GetIndentString(indent, '.'), typeText, method, text);
            Trace.WriteLine(fullText);
        }

        public void Write(string text)
        {
            throw new NotImplementedException();
        }

        public bool SimpleWriter
        {
            get { return false; }
        }
        #endregion

        public void WriteLine(string text)
        {
        }

        public void Dispose()
        {
        }
    }
}